package com.neu.envprotection.admin.controller;

import com.neu.envprotection.admin.dao.entity.User;
import com.neu.envprotection.admin.dto.resp.GetVerifyCodeRespDto;
import com.neu.envprotection.admin.service.UserService;
import com.neu.envprotection.common.constant.SystemConfigConsts;
import com.neu.envprotection.common.resp.RestResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/inner/admin")
@RequiredArgsConstructor
@SecurityRequirement(name = SystemConfigConsts.HTTP_AUTH_HEADER_NAME)
@Tag(name = "用户管理服务内部接口")
@Slf4j
public class UserInnerController {
    @Autowired
    private UserService userService;

    @PostMapping("/selectById/{id}")
    @Operation(summary = "内部调用查找用户")
    RestResp<User> selectUserById(@PathVariable Integer id){
        return userService.getUserById(id);
    }

    @PostMapping("/updateById")
    @Operation(summary = "内部调用更新用户")
    RestResp<Void> updateById(@RequestBody User user){
        return userService.updateById(user);
    }


    @PostMapping("/storeVerifyCode")
    @Operation(summary = "内部储存验证码")
    RestResp<Void> storeVerifyCode(@RequestBody GetVerifyCodeRespDto dto){
        return userService.storeVerifyCode(dto);
    }

}
